package com.zhong.controller;

import com.zhong.po.Emp;
import com.zhong.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController  //@Controller + @ResponseBody
@RequestMapping("/api/emp")
public class EmpController {

    @Autowired
    private EmpService empService;

    @RequestMapping("/selectByPrimaryKey")
    public Emp view(int id){
        return empService.selectByPrimaryKey(id);
    }

    @RequestMapping("/selectByExample")
    public List<Emp> selectByExample(String job, int deptNo){
        return empService.selectByExample(job, deptNo);
    }

    //超5个参数的， 就用对象接收
    @RequestMapping("/insert")
    public String insert(Emp emp){
        return empService.insert(emp);
    }

    @RequestMapping("/insertSelective")
    public String insertSelective(Emp emp){
        return empService.insertSelective(emp);
    }

    @RequestMapping("/updateByPrimaryKey")
    public String updateByPrimaryKey(Emp emp){
        empService.updateByPrimaryKey(emp);
        return "ok";
    }

    @RequestMapping("/updateByPrimaryKeySelective")
    public String updateByPrimaryKeySelective(Emp emp){
        empService.updateByPrimaryKeySelective(emp);
        return "ok";
    }

    public String updateByExample(Emp emp){
        empService.updateByExample(emp);
        return "ok";
    }

    public String updateByExampleSelectiv(Emp emp){
        empService.updateByPrimaryKeySelective(emp);
        return "ok";
    }



}
